package com.dz.service.impl;

import com.dz.bean.Manager;
import com.dz.mapper.ManagerDao;
import com.dz.service.ManagerService;
import com.dz.util.Page;
import com.dz.util.PasswordUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ManagerServiceImpl implements ManagerService {
    @Autowired
    ManagerDao managerDao;

    @Override
    public Manager add(Manager manager) {
        managerDao.add(manager);
        Manager result = managerDao.findById(manager.getId());
        return result;
    }

    @Override
    public int delete(Integer id) {
        return managerDao.delete(id);
    }

    @Override
    public Manager edit(Manager manager) {
        managerDao.edit(manager);
        Manager result = managerDao.findById(manager.getId());
        return result;
    }

    @Override
    public List<Manager> all(Manager manager) {
        return managerDao.all(manager);
    }

    @Override
    public Manager findById(Integer id) {
        return managerDao.findById(id);
    }

    @Override
    public void page(Page page, Manager manager) {
        int totalCount = managerDao.pageCount(manager);
        Object data = managerDao.page(page,manager);
        page.setTotalCount(totalCount);
        page.setData(data);
    }
}
